package com.mt.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.mt.pojo.User;

/**
 * @author Wang
 * @Description JWT 工具类
 * @date 2020/11/15-14:10
 */
public class JWTUtil {
    //加密,获取token
    public static String getToken(User user){
        String jwt = JWT.create().withClaim("userName", user.getUserName())
                .withClaim("userId",user.getUserId())
                .sign(Algorithm.HMAC256(user.getPassword()));
        return jwt;
    }
}
